using System;
using System.Collections.Generic;
using PeterInterface;
using WeifenLuo.WinFormsUI.Docking;
using System.Windows.Forms;
using System.Drawing;

namespace BeHexEditor
{
    [PeterPlugin(PeterPluginType.DockWindow)]
    public class HexEditor : IPeterPlugin
    {
        private IPeterPluginHost m_Host;

        public HexEditor()
        {
        }

        #region IPeterPlugin Members

        public bool AbleToLoadFiles
        {
            get { return false; }
        }

        public void ActiveContentChanged(IDockContent tab)
        {
        }

        public void ApplyOptions()
        {
        }

        public string Author
        {
            get { return "Bernhard Elbl"; }
        }

        public bool CheckContentString(string contentString)
        {
            return (contentString == typeof(ctrlHexEdit).ToString());
        }

        public void Close()
        {
        }

        public IDockContent GetContent(string contentString)
        {
            return new ctrlHexEdit();
        }

        public ToolStripMenuItem GetMenu()
        {
            ToolStripMenuItem tsmi = new ToolStripMenuItem("Be.HexEditor");
            tsmi.Image = this.PluginImage;
            tsmi.Click += new EventHandler(CreateNewHexEditor);

            return tsmi;
        }

        void CreateNewHexEditor(object sender, EventArgs e)
        {
            this.m_Host.AddDockContent(new ctrlHexEdit(), DockState.Document);
        }

        void ViewInHexEditor(object sender, EventArgs e)
        {

        }

        public ToolStripMenuItem[] GetContextMenu()
        {
            ToolStripMenuItem[] menu = new ToolStripMenuItem[1];
            menu[0] = new ToolStripMenuItem("View in Hex Editor");
            menu[0].Image = this.PluginImage;
            menu[0].Click += new EventHandler(ViewInHexEditor);

            return menu;
        }

        public ToolStripMenuItem[] GetTabMenu()
        {
            ToolStripMenuItem[] menu = new ToolStripMenuItem[1];
            menu[0] = new ToolStripMenuItem("View in Hex Editor");
            menu[0].Image = this.PluginImage;
            menu[0].Click += new EventHandler(ViewInHexEditor);

            return menu;
        }

        public bool HasContextMenu
        {
            get { return true; }
        }

        public bool HasMenu
        {
            get { return true; }
        }

        public bool HasTabMenu
        {
            get { return true; }
        }

        public IPeterPluginHost Host
        {
            get { return this.m_Host; }

            set { this.m_Host = value; }
        }

        public bool LoadFile(string filePath)
        {
            return false;
        }

        public string Name
        {
            get { return "Be.HexEditor"; }
        }

        public Control OptionPanel
        {
            get { return null; }
        }

        public Image PluginImage
        {
            get
            {
                System.Reflection.Assembly assem;
                assem = this.GetType().Assembly;
                System.Resources.ResourceManager mngr = new System.Resources.ResourceManager("BeHexEditor.InternalImages", assem);
                return (Image)mngr.GetObject("Icon");
            }
        }

        public void Start()
        {
        }

        public PeterPluginType Type
        {
            get { return PeterPluginType.DockWindow; }
        }

        public string Version
        {
            get { return "1.2"; }
        }

        #endregion
    }
}
